package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/6.
 */
@HttpInlet(Conn.INLET_API_CONSULT_MY)
public class GetApiWoDeZiXun extends BaseAsyGet<GetApiWoDeZiXun.Info> {

    public String userid;

    public GetApiWoDeZiXun(AsyCallBack<GetApiWoDeZiXun.Info> asyCallBack) {
        super(asyCallBack);
    }


    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200) {

            JSONArray array = jsonObject.optJSONArray("data");
            Info info = new Info();
            for (int i = 0; i < array.length(); i++) {

                JSONObject o = array.optJSONObject(i);
                Data d = new Data();

                d.id = o.optString("id");
                d.reply = o.optString("reply");
                d.uid = o.optString("uid");
                d.username = o.optString("username");
                d.restate = o.optString("restate");
                d.posttime = o.optString("posttime");
                d.title = o.optString("title");
                d.picurl = Conn.IMGURL + o.optString("picurl");

                info.dataList.add(d);

            }
            return info;
        }
        return null;
    }

    public static class Info {

        public List<Data> dataList = new ArrayList<>();
    }

    public static class Data {

        public String id, title, reply, uid, username, posttime, restate, picurl;
    }
}
